import { createRouter, createWebHistory } from 'vue-router'

import Layout from '../layout/index.vue'

const routes = [
  {
    name: 'login',
    path: '/login',
    component: () => import('../views/login.vue')
  },
  {
    name: '404',
    path: '/404',
    component: () => import('../views/error/404.vue')
  },
  {
    name: '401',
    path: '/401',
    component: () => import('../views/error/401.vue')
  },
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    children: [
      { path: '', redirect: 'home' },
      {
        name: 'home',
        path: '/home',
        component: () => import('../views/home/home.vue'),
      },
      {
        name: 'cart',
        path: '/cart',
        component: () => import('../views/cart/cart.vue')
      },
      {
        name: 'checkout',
        path: '/checkout',
        component: () => import('../views/checkout/checkout.vue')
      },
      {
        name: 'topUp',
        path: '/topUp',
        component: () => import('../views/topUp/topUp.vue')
      },
    ]
  },
  {
    name: 'member',
    path: '/member',
    component: Layout,
    children: [
      {
        name: 'center',
        path: 'center',
        component: () => import('../views/member/center.vue')
      }
    ]
  },
  {
    name: 'goods',
    path: '/goods',
    component: Layout,
    children: [
      {
        name: 'list',
        path: 'list/:productCategoryId(\\d+)',
        component: () => import('../views/goods/goods.vue')
      },
      {
        name: 'detail',
        path: 'detail',
        component: () => import('../views/goods/detail.vue')
      },
      {
        name: 'all',
        path: 'all',
        component: () => import('../views/goods/goods.vue')
      }
    ]
  },
  {
    name: 'order',
    path: '/order',
    component: Layout,
    children: [
      {
        name: 'orderItems',
        path: 'orderItems',
        component: () => import('../views/order/orderItems.vue')
      },
      {
        name: 'payment',
        path: 'payment',
        component: () => import('../views/order/payment.vue')
      },
      {
        name: 'progress',
        path: 'progress',
        component: () => import('../views/order/progress.vue')
      },
      {
        name: 'evaluation',
        path: 'evaluation',
        component: () => import('../views/order/evaluation.vue')
      }
    ]
  },
]
export default createRouter({
  history: createWebHistory(),
  routes
})
